# -*- coding: utf-8 -*-
# @Time: 2023/4/20 22:57
# @File: froms.py
# @Desc:cms管理后台表单类

from apps.front.forms import BaseForm
from wtforms.fields import FileField
from flask_wtf.file import FileAllowed, FileSize
from wtforms import StringField, IntegerField
from wtforms.validators import InputRequired


# 上传轮播图
class UploadBannerForm(BaseForm):
    image = FileField(validators=[
        FileAllowed(['jpg', 'png', 'jpeg'], message="图像格式仅支持jpg、jpeg、png"),
        FileSize(max_size=5 * 1024 * 1024, message="图像最大不能超过5M")])


# 添加轮播图
class AddBannerForm(BaseForm):
    name = StringField(validators=[InputRequired(message="请传入图片名称")])
    img_url = StringField(validators=[InputRequired(message="请输入图片链接！")])
    url_to = StringField(validators=[InputRequired(message="请输入图片跳转链接")])
    priority = IntegerField(validators=[InputRequired(message="请输入图片优先级")])


# 编辑轮播图
class EditBannerForm(AddBannerForm):
    id = IntegerField(validators=[InputRequired(message="请指定轮播图进行删除操作")])
